package com.cpi.cornpp.biweeks.converter;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;

import com.cpi.cornpp.biweeks.dto.BiWeekPeriodVersionDTO;
import com.cpi.cornpp.biweeks.view.BiWeekPeriodVersionView;

public class BiWeekPeriodVersionConverter {
	public static BiWeekPeriodVersionView convert(BiWeekPeriodVersionDTO dto){
		BiWeekPeriodVersionView view = null;
		
		if (dto != null){
			view = new BiWeekPeriodVersionView();
			
			view.setBiWeekPeriodVersionId(dto.getBiWeekPeriodVersionId());
			view.setBiWeekPeriodId(dto.getBiWeekPeriodId());
			view.setVersionId(dto.getVersionId());
		}
		
		return view;
	}
	
	public static BiWeekPeriodVersionDTO convert(BiWeekPeriodVersionView view){
		BiWeekPeriodVersionDTO dto = null;
		
		if (view != null){
			dto = new BiWeekPeriodVersionDTO();
			
			dto.setBiWeekPeriodVersionId(view.getBiWeekPeriodVersionId());
			dto.setBiWeekPeriodId(view.getBiWeekPeriodId());
			dto.setVersionId(view.getVersionId());
		}
		
		return dto;
	}
	
	public static List convertDTOList(List dtoList){
		List viewList = null;
		
		viewList = new ArrayList(0);
		
		if (CollectionUtils.isNotEmpty(dtoList)){
			
			for (Iterator itr = dtoList.iterator(); itr.hasNext(); ){
				viewList.add(convert((BiWeekPeriodVersionDTO) itr.next()));
			}
		}
		
		return viewList;
	}
	
	public static List convertViewList(List viewList){
		List dtoList = null;
		
		dtoList = new ArrayList(0);
		
		if (CollectionUtils.isNotEmpty(viewList)){
			
			for (Iterator itr = viewList.iterator(); itr.hasNext(); ){
				dtoList.add(convert((BiWeekPeriodVersionView) itr.next()));
			}
		}
		
		return dtoList;
	}
}